}
GVariant *
-ostree_get_xattrs_for_path (const char *path,
- GError **error)
+ostree_get_xattrs_for_file (GFile *f,
+ GError **error)
{
+ const char *path;
GVariant *ret = NULL;
GVariantBuilder builder;
char *xattr_names = NULL;
char *xattr_names_canonical = NULL;
ssize_t bytes_read;
+ path = ot_gfile_get_path_cached (f);
+
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(ayay)"));
bytes_read = llistxattr (path, NULL, 0);
struct stat *out_stbuf,
GError **error)
{
+ GFile *f = NULL;
GChecksum *content_sha256 = NULL;
GChecksum *content_and_meta_sha256 = NULL;
char *stat_string = NULL;
char *device_id = NULL;
struct stat stbuf;
+ f = ot_util_new_file_for_path (path);
+
basename = g_path_get_basename (path);
if (dir_fd == -1)
if (objtype == OSTREE_OBJECT_TYPE_FILE)
{
- xattrs = ostree_get_xattrs_for_path (path, error);
+ xattrs = ostree_get_xattrs_for_file (f, error);
if (!xattrs)
goto out;
}
*out_checksum = content_and_meta_sha256;
ret = TRUE;
out:
+ g_clear_object (&f);
if (fd >= 0)
close (fd);
if (temp_dir != NULL)
goto out;
}
- xattrs = ostree_get_xattrs_for_path (ot_gfile_get_path_cached (dir), error);
+ xattrs = ostree_get_xattrs_for_file (dir, error);
if (!xattrs)
goto out;
}
gboolean
-ostree_set_xattrs (const char *path, GVariant *xattrs, GCancellable *cancellable, GError **error)
+ostree_set_xattrs (GFile *f,
+ GVariant *xattrs,
+ GCancellable *cancellable,
+ GError **error)
{
+ const char *path;
gboolean ret = FALSE;
int i, n;
+ path = ot_gfile_get_path_cached (f);
+
n = g_variant_n_children (xattrs);
for (i = 0; i < n; i++)
{
GError **error)
{
gboolean ret = FALSE;
- const char *path = NULL;
GFileInfo *finfo = NULL;
GFileInputStream *instream = NULL;
gboolean pack_builder_initialized = FALSE;
GVariant *xattrs = NULL;
gsize bytes_written;
- path = ot_gfile_get_path_cached (file);
-
finfo = g_file_query_info (file, "standard::type,standard::size,standard::is-symlink,standard::symlink-target,unix::*",
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, cancellable, error);
if (!finfo)
g_variant_builder_add (&pack_builder, "u", GUINT32_TO_BE (gid));
g_variant_builder_add (&pack_builder, "u", GUINT32_TO_BE (mode));
- xattrs = ostree_get_xattrs_for_path (path, error);
+ xattrs = ostree_get_xattrs_for_file (file, error);
if (!xattrs)
goto out;
g_variant_builder_add (&pack_builder, "@a(ayay)", xattrs);
}
}
- if (!ostree_set_xattrs (dest_path, xattrs, NULL, error))
+ if (!ostree_set_xattrs (file, xattrs, NULL, error))
goto out;
if (ret_checksum)
GError **error)
{
gboolean ret = FALSE;
+ GFile *dest_file = NULL;
char *dest_path = NULL;
GVariant *xattr_variant = NULL;
dest_path = g_build_filename (destination, dirname, NULL);
+ dest_file = ot_util_new_file_for_path (dest_path);
if (!_ostree_repo_file_get_xattrs (dir, &xattr_variant, NULL, error))
goto out;
goto out;
}
- if (!ostree_set_xattrs (dest_path, xattr_variant, cancellable, error))
+ if (!ostree_set_xattrs (dest_file, xattr_variant, cancellable, error))
goto out;
if (!checkout_tree (self, dir, dest_path, cancellable, error))
ret = TRUE;
out:
+ g_clear_object (&dest_file);
g_free (dest_path);
if (xattr_variant)
g_variant_unref (xattr_variant);